package com.game.doudizhu.core;

import com.game.doudizhu.model.Card;

import java.util.ArrayList;
import java.util.List;

public class GameUtil {

    public static List<Card> initializeCards() {
        List<Card> cards = new ArrayList<>();
        long id = 1;

        // 常规牌
        String[] suits = {"HEARTS", "DIAMONDS", "CLUBS", "SPADES"};
        String[] ranks = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};

        for (String suit : suits) {
            for (String rank : ranks) {
                Card card = new Card();
                card.setId(id++);
                card.setSuit(Card.Suit.valueOf(suit));
                card.setRank(rank);
                card.setWeight(getWeight(rank));
                cards.add(card);
            }
        }

        // 小王
        Card smallJoker = new Card();
        smallJoker.setId(id++);
        smallJoker.setSuit(Card.Suit.JOKER);
        smallJoker.setRank("SMALL");
        smallJoker.setWeight(16);
        cards.add(smallJoker);

        // 大王
        Card bigJoker = new Card();
        bigJoker.setId(id);
        bigJoker.setSuit(Card.Suit.JOKER);
        bigJoker.setRank("BIG");
        bigJoker.setWeight(17);
        cards.add(bigJoker);

        return cards;
    }

    public static int getWeight(String rank) {
        switch (rank) {
            case "3": return 3;
            case "4": return 4;
            case "5": return 5;
            case "6": return 6;
            case "7": return 7;
            case "8": return 8;
            case "9": return 9;
            case "10": return 10;
            case "J": return 11;
            case "Q": return 12;
            case "K": return 13;
            case "A": return 14;
            case "2": return 15;
            default: return 0;
        }
    }

}
